package cn.itcast.order;

import cn.itcast.feign.config.DefaultFeignConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@MapperScan("cn.itcast.order.mapper")
@SpringBootApplication
//@EnableFeignClients(defaultConfiguration = DefaultFeignConfig.class, basePackages = "cn.itcast.feign.clients")   // 全局有效    // 指定FeignClient所在包，加载所有client
//@EnableFeignClients(defaultConfiguration = DefaultFeignConfig.class, clients = {UserClient.class})   // 全局有效    // 指定FeignClient字节码，加载指定client
@EnableFeignClients(defaultConfiguration = DefaultFeignConfig.class, basePackages = "cn.itcast.feign.clients")   // 全局有效    // 指定FeignClient字节码，加载指定client
public class OrderApplication {

    /**
     * 创建RestTemplate并注入Spring容器
     * @return RestTemplate
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }

}